#!/bin/bash
# 判断文件夹是否存在
source_dir="/opt/source/"
haproxy_dir="/opt/source/haproxy-stable/"
# 文件名称
haproxy_name="haproxy-stable.tar.gz"
# 安装文件路径
haproxy_command="/usr/local/haproxy/"
if [ ! -d $haproxy_dir ]; then
       mkdir -p $haproxy_dir
fi
cd $source_dir
if [ ! -f $source_dir$haproxy_name ];then
wget https://www.haproxy.org/download/2.0/src/haproxy-2.0.8.tar.gz -O $haproxy_name
fi
tar -xvf $haproxy_name -C $haproxy_dir  --strip-components 1
cd $haproxy_dir

sudo apt install make -y
sudo apt install gcc -y
dir=$(uname -r)
sudo make TARGET=$dir PREFIX=$haproxy_command
sudo make install PREFIX=$haproxy_command
cd $haproxy_command
touch haproxy.cfg
